package com.gdqy.FCS.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.gdqy.FCS.entity.ClothingType;
import com.gdqy.FCS.service.ClothingTypeService;

@Controller
@RequestMapping("clothingType")
public class ClothingTypeController {
	
	@Autowired
	private ClothingTypeService clothingTypeService;
	
	
	@RequestMapping("admin_clothingType")
	public ModelAndView admin_clothingType() {
		ModelAndView modelAndView = new ModelAndView();
		List<ClothingType> clothingTypes = clothingTypeService.selectAll();
		modelAndView.addObject("clothingTypes", clothingTypes);
		modelAndView.setViewName("admin/dictionaryClothes");
		return modelAndView;
	}
	
	@RequestMapping("add_clothingType")
	public @ResponseBody String add_clothingType(ClothingType clothingType) {
		String msg = "fail";
		int data = clothingTypeService.insert(clothingType);
		if(data>0) {
			msg="success";
		}
		
		return msg;
	}
	
}
